<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="include.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>login</title>
    <style type="text/css">
		.box{
			 width: 600px;
			 height: 400px;
			 background: ;
			 position: absolute;
			 left: 70%;
			 top:70%;
			 margin-left: -800px;
			 margin-top: -370px;
			 text-align: center;
		}
		.input_box{
			 width:350px;
			 padding-bottom: 18px;
			 border:4;
			 color:orange;
			 margin: 0 auto;
			 font-weight:bold;
			 overflow: hidden;
		}
		.ui-btn{
		    border: none;
		    color: white;
		    text-align: center;
		    text-decoration: none;
		    display: inline-block;
		    font-size: 17px;
		    margin: 4px 2px;
		    cursor: pointer;
		
		}
		.title{
			 color: orange;
		}
		
    </style>
    <script type="text/javascript">
    	$(function(){
    		//给提交button添加单击事件
    		$("#loginSubmitBtn").click(function(){
    			login();
    	    });
    	    
    	    //给密码输入框添加键盘松开事件
    	    $("#pwd").keyup(function(event){
			 	var v=event.keyCode;
			 	if(v==13){//捕获enter键
			 		login();
			 	}
			});
    	    
    	});
    	
    	/**
    		登录的方法
    	*/
    	function login(){
    		//获取用户名和密码
   			var userName=$("#name").val();
   			var pwd=$("#pwd").val();
   			//发送到后台进行验证
   			$.post("<%=path%>/user/login.do",{userName:userName,pwd:pwd},
			   		function(data){
			     	if(data==true){//验证成功
			     		//自动去主页面
			     		window.location.href="<%=path%>/main.jsp";
			     	}else{
			     		//验证不成功
			     		$.messager.show({
							title:'我的消息',
							msg:"用户名或密码有误!",
							timeout:3000,
							showType:'slide'
						});
			     	}
			},"json");
    	}
    	
    	
    </script>
  </head>
  
  <body>
  	<div class="box">
  		<div class="title">
  			<h1 align="center"></h1>
<%--			<h1 align="center">宝鸡地震灾害风险调查</h1>--%>
  		</div>
 		<br/>
		<div class="input_box">
			帐号:&nbsp;&nbsp;<input type="text" id="name" name="userName" value="admin" placeholder="请输入用户名" style="border-radius:8px;width:200px;height:30px"/><br>
		</div>
		<div class="input_box">
			密码:&nbsp;&nbsp;<input type="text" id="pwd" name="pwd" value="123456" placeholder="请输入密码" style="border-radius:8px;width:200px;height:30px"/><br><br>
		</div>
		<div class="ui-btn">
			<input id="loginSubmitBtn" type="button" value="登录" style="width:99px;height:30px"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		</div>
	</div>	
    
  </body>
</html>
